/**============================================================================
 *
 * Author: luo1o1o1o 
 *
 * QQ: 330240995, PHONE: 17600071321
 *
 * Last modified: 2021-06-08 10:42
 *
 * Filename: cryp.js
 *
 * Description: 加密方法
 *
 ============================================================================**/

const crypto = require('crypto')
// 秘钥
const { CRYPTO_SECRET_KEY } = require('../conf/secretKeys')

/**
 * @Author: luo1o1o1o
 * @QQ: 330240995, @PHONE: 17600071321
 * @Date: 2021-06-08 10:42
 * @desc: md5加密
 */
function _md5(content) {
    const md5 = crypto.createHash('md5')
    return md5.update(content).digest('hex') //16进制
}
/**
 * @Author: luo1o1o1o
 * @QQ: 330240995, @PHONE: 17600071321
 * @Date: 2021-06-08 10:57
 * @desc: 加密方法
 */
function doCrypto(content) {
    const str = `password=${content}&key=${CRYPTO_SECRET_KEY}`
    return _md5(str)
}

module.exports = doCrypto
